import java.util.Arrays;
import java.util.Scanner;

public class Main1214 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        int[] arr1=new int[arr.length+1];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = sc.nextInt();
        }
        int y = sc.nextInt();
        int max=arr[0];
        int a=0;
        for (int i=0;i<arr.length;i++){
            if (arr[i]>max){
                max=arr[i];
                a++;
            }
        }
        //System.out.println(max);
       // System.out.println(a);
        for (int i=0;i<arr.length;i++) {
            arr1[i] = arr[i];
        }
        for (int i=arr1.length-1;i>a+1;i--){
                arr1[i]=arr1[i-1];
            }
            arr1[a+1]=y;
            arr=arr1;
        //System.out.println(Arrays.toString(arr));
         for (int i=0;i< arr.length;i++){
                 System.out.print(arr[i]+" ");
            }
        }
    }
